package appapi.dao;

import appapi.entity.mqtt.Interference;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @version: java version 1.8
 * @Author: Ygp Work
 * @description:
 * @date: 2023-07-05 17:21
 */
@Mapper
public interface InterferenceMapper {
    @Insert("INSERT INTO interference (equipmentimel, towername, towerheight, forearmlength, reararmlength, towertopheight, xcoordinate, ycoordinate,devices_id) " +
            "VALUES (#{equipmentimel}, #{towername}, #{towerheight}, #{forearmlength}, #{reararmlength}, #{towertopheight}, #{xcoordinate}, #{ycoordinate}, #{devicesId})")
    void insertInterference(Interference interference);

    @Update("UPDATE interference SET equipmentimel = #{equipmentimel}, towername = #{towername}, towerheight = #{towerheight}, " +
            "forearmlength = #{forearmlength}, reararmlength = #{reararmlength}, towertopheight = #{towertopheight}, " +
            "xcoordinate =#{xcoordinate}, ycoordinate = #{ycoordinate} WHERE id = #{id}")
    void updateInterference(Interference interference);

    @Delete("DELETE FROM interference WHERE id = #{id}")
    void delInterference(Long id);

    @Select("SELECT i.* FROM devices d JOIN interference i ON d.devices_id = i.devices_id WHERE d.devices_id = #{devicesId}")
    List<Interference> getInterferenceById(Long devicesId);

    @Select("SELECT * from interference")
    List<Interference> getAllInterference(Interference interference);
}
